import TopNavict from "../compoments/TopNavict"
import company from "./styles/companyInfo.module.css"
import BottomBavict from "../compoments/bottomnav"
import classNames from "classnames"
import { useState } from "react"
import Sample from "../compoments/sample"
import OrderBuy from "../compoments/orderbuy"
import Cust from "../compoments/cust"
import { useLocation } from "react-router-dom"
import { useEffect } from "react"

const CompanyInfo = () => {
    const location = useLocation()
    const [currentId,setCurrentId] = useState(1)
    const choice = (id) => {
        setCurrentId(id)
    }
    useEffect(()=>{
        const cur_ = location.state.id
        //将id转为整数
        const cur_id = parseInt(cur_)
        setCurrentId(cur_id)
    },[])
    return (
        <div>
            <TopNavict/>
            <div className={company.line}>
            </div>
            <div className={company.info}>
                <div className={company.info_left}>
                    {
                        currentId === 1 ? <Sample/> : currentId === 3 ? <OrderBuy/> : currentId === 2 ? <Cust/> : <Sample/>
                    }
                </div>
                <div className={company.info_right}>
                    <div className={company.option}>
                        <div className={company.title}>企业专区</div>
                        <div className={classNames(company.txt,{[company.txt_active]:currentId === 1})} onClick={()=>{choice(1)}}>试吃申请</div>
                        <div className={classNames(company.txt,{[company.txt_active]:currentId === 2})} onClick={()=>{choice(2)}}>下午茶/茶歇高级定制服务</div>
                        <div className={classNames(company.txt,{[company.txt_active]:currentId === 3})} onClick={()=>{choice(3)}}>大宗购买</div>
                    </div>
                </div>
            </div>
            <BottomBavict/>
        </div>
    )
}

export default CompanyInfo